﻿using ExtensionControls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ColumnComposer
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            PersonViewModelCollection collection = new PersonViewModelCollection();
            List<EPersonColumn> columnTypes = new List<EPersonColumn>();

            collection.AddColumn(EPersonColumn.CITY);
            collection.AddColumn(EPersonColumn.NAME);
            collection.AddColumn(EPersonColumn.SURNAME);
            collection.AddColumn(EPersonColumn.MAN);
            

            collection.AddItem(new PersonViewModel(new Person("Mateusz", "Meller", "Gdańsk", true)));
            collection.AddItem(new PersonViewModel(new Person("Irena", "Meller", "Suwałki", false)));

            this.grid.Collection = collection;

            this.grid.loadData();
        }

        private void sayHelloButtonClick(object sender, EventArgs e)
        {
            int objectIndex = this.grid.FindObjectIndex();
            foreach (DataGridViewRow selectedRow in this.grid.SelectedRows)
            {
                PersonViewModel personVM = (PersonViewModel)selectedRow.Cells[objectIndex].Value;
                MessageBox.Show(personVM.SayHello());
            }
 
        }

        private void sayHelloButton_Click(object sender, EventArgs e)
        {
            this.grid.sayHello();
        }

        private void updateRowButton_Click(object sender, EventArgs e)
        {
            this.grid.updateRows();
        }
    }
}
